home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 27 / CDROM27.iso / share / progra / mai / Common Dialog, Format Drive - called with API < prev    next >
Encoding:
Text File  |  1997-07-13  |  1.6 KB  |  53 lines

  1. 'Description: Calls the "Format Drive Dialog" without need for an OCX
  2.  
  3. 'fmtID-
  4. '   3.5"    5 1/4"
  5. '----------------
  6. ' 0 1.44    1.2
  7. ' 1 1.44    1.2
  8. ' 2 1.44    1.2
  9. ' 3 1.44    360
  10. ' 4 1.44    1.2
  11. ' 5 720     1.2
  12. ' 6 1.44    1.2
  13. ' 7 1.44    1.2
  14. ' 8 1.44    1.2
  15. ' 9 1.44    1.2
  16.  
  17. 'options (sfo= system files only)
  18. ' 0 Quick Quick
  19. ' 1 Full  Full
  20. ' 2 sfo   sfo
  21. ' 3 sfo   sfo
  22. ' 4 Quick Quick
  23. ' 5 Full  Full
  24. ' 6 sfo   sfo
  25. ' 7 sfo   sfo
  26. ' 8 Quick Quick
  27. ' 9 Full Full
  28. '------------------------------------
  29.  
  30. 'Private Declare Function SHFormatDrive Lib "shell32" (ByVal hwnd As Long, ByVal Drive As Long, ByVal fmtID As Long, ByVal options As Long) As Long
  31. 'Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
  32.  
  33.  
  34. 'Place the following code in under a command button or in a menu, etc...
  35.  
  36.     Dim DriveLetter$, DriveNumber&, DriveType&
  37.     Dim RetVal&, RetFromMsg%
  38.     DriveLetter = UCase(Drive1.Drive)
  39.     DriveNumber = (Asc(DriveLetter) - 65) ' Change letter to Number: A=0
  40.     DriveType = GetDriveType(DriveLetter)
  41.     If DriveType = 2 Then  'Floppies, etc
  42.         RetVal = SHFormatDrive(Me.hwnd, DriveNumber, 0&, 0&)
  43.     Else
  44.         RetFromMsg = MsgBox("This drive is NOT a removeable" & vbCrLf & _
  45.             "drive! Format this drive?", 276, "SHFormatDrive Example")
  46.         Select Case RetFromMsg
  47.             Case 6   'Yes
  48.                 ' UnComment to do it...
  49.                 'RetVal = SHFormatDrive(Me.hwnd, DriveNumber, 0&, 0&)
  50.             Case 7   'No
  51.                 ' Do nothing
  52.         End Select
  53.     End If